package com.lzb.findphone.activity;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.lzb.findphone.BaseAc;
import com.lzb.findphone.R;
import com.lzb.findphone.adapter.HomeSoundAdapter;
import com.lzb.findphone.bean.SoundBean;
import com.lzb.findphone.databinding.ActivityMoreSoundBinding;

import java.util.ArrayList;
import java.util.List;

public class MoreSoundActivity extends BaseAc<ActivityMoreSoundBinding> implements OnItemClickListener {

    private HomeSoundAdapter soundAdapter;

    @Override
    protected int onCreate() {
        return R.layout.activity_more_sound;
    }

    @Override
    protected void initView() {
        mDataBinding.ivMoreSoundBack.setOnClickListener(view -> getOnBackPressedDispatcher().onBackPressed());

        mDataBinding.rvSoundList.setLayoutManager(new GridLayoutManager(mContext, 3));
        soundAdapter = new HomeSoundAdapter();
        mDataBinding.rvSoundList.setAdapter(soundAdapter);
        soundAdapter.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        SoundActivity.soundPos = position;
        startActivity(SoundActivity.class);
    }

    @Override
    protected void initData() {
        List<SoundBean> listData = new ArrayList<>();
        listData.add(new SoundBean(R.drawable.icon_dog, R.drawable.icon_dog2, "狗", R.raw.gou, false));
        listData.add(new SoundBean(R.drawable.icon_police, R.drawable.icon_police2, "警察", R.raw.jingcha, false));
        listData.add(new SoundBean(R.drawable.icon_cattle, R.drawable.icon_cattle2, "牛", R.raw.niu, false));
        listData.add(new SoundBean(R.drawable.icon_sheep, R.drawable.icon_sheep2, "羊", R.raw.yang, false));
        listData.add(new SoundBean(R.drawable.icon_frog, R.drawable.icon_frog2, "青蛙", R.raw.qingwa, false));
        listData.add(new SoundBean(R.drawable.icon_pig, R.drawable.icon_pig2, "猪", R.raw.zhu, false));
        listData.add(new SoundBean(R.drawable.icon_goast, R.drawable.icon_goast2, "鬼", R.raw.gui, false));
        listData.add(new SoundBean(R.drawable.icon_baby, R.drawable.icon_baby2, "婴儿", R.raw.yinger, false));
        listData.add(new SoundBean(R.drawable.icon_car, R.drawable.icon_car2, "卡车", R.raw.kache, false));
        listData.add(new SoundBean(R.drawable.icon_police_car, R.drawable.icon_police_car2, "警车", R.raw.jingche, false));
        listData.add(new SoundBean(R.drawable.icon_laba, R.drawable.icon_laba2, "喇叭", R.raw.laba, false));
        listData.add(new SoundBean(R.drawable.icon_lightning, R.drawable.icon_lightning2, "闪电", R.raw.shandian, false));
        listData.add(new SoundBean(R.drawable.icon_clock, R.drawable.icon_clock2, "闹钟", R.raw.naozhong, false));
        soundAdapter.setList(listData);
    }
}